import Vue from 'vue'
import Router from 'vue-router'
import store from '../vuex'

import IndexPage from '@/pages/index'
import BindPhonePage from '@/pages/bindPhone'
import PersonalInfoPage from '@/pages/personalInfo'
import SubscribeServicesPage from '@/pages/subscribeServices'
import AddSubscribePage from '@/pages/subscribeServices/addSubscribe'
import HolidayPartyListPage from '@/pages/subscribeServices/holidayPartyList'
import HolidayPartyDetailPage from '@/pages/subscribeServices/holidayPartyDetail'
import ToPayDepositPage from '@/pages/subscribeServices/toPayDeposit'
import SubscribeDetailPage from '@/pages/subscribeServices/subscribeDetail'
import DepositTermPage from '@/pages/subscribeServices/depositTerm'
import NoticeListPage from '@/pages/noticeList'
import NoticeDetailPage from '@/pages/noticeDetail'
import KeepServicesPage from '@/pages/keepServices'
import KeepDetailPage from '@/pages/keepServices/keepDetail'
import ChooseWithDrawPage from '@/pages/keepServices/chooseWithDraw'
import CallServicesPage from '@/pages/callServices'
import ScanActionPage from '@/pages/callServices/scanAction'
import CallKeepDetailPage from '@/pages/callServices/callKeepDetail'
import CallServiceDetailPage from '@/pages/callServices/callServiceDetail'
import ComplaintDetailPage from '@/pages/callServices/complaintDetail'
import MemberCardPage from '@/pages/memberCard'
import PayCodePage from '@/pages/memberCard/payCode'
import CardListPage from '@/pages/memberCard/cardList'
import CardDetailPage from '@/pages/memberCard/cardDetail'
import CardChargePage from '@/pages/memberCard/cardCharge'

Vue.use(Router)

const router = new Router({
  //mode:'history',//网址没有了#号，hBuilder打包成APP不能使用，需要注释
  base: '/member/',
  routes: [
    {
      path: '/',
      name: '主页',
      component: IndexPage
    },
    {
      path: '/bindPhone',
      name: '绑定手机',
      component: BindPhonePage
    },
    {
      path: '/personalInfo',
      name: '个人信息',
      component: PersonalInfoPage
    },
    {
      path: '/subscribeServices',
      name: '我的预订',
      component: SubscribeServicesPage
    },
    {
      path: '/addSubscribe/:subscribe',
      name: '增加预订',
      component: AddSubscribePage
    },
    {
      path: '/holidayPartyList',
      name: '节日/派对列表',
      component: HolidayPartyListPage
    },
    {
      path: '/holidayPartyDetail/:holidayPartyId',
      name: '节日/派对详情',
      component: HolidayPartyDetailPage
    },
    {
      path: '/toPayDeposit/:subscribeId',
      name: '订金支付',
      component: ToPayDepositPage
    },
    {
      path: '/subscribeDetail/:subscribeId',
      name: '预订详情',
      component: SubscribeDetailPage
    },
    {
      path: '/depositTerm',
      name: '预订协议',
      component: DepositTermPage
    },
    {
      path: '/noticeList',
      name: '消息中心',
      component: NoticeListPage
    },
    {
      path: '/noticeDetail/:noticeId',
      name: '消息详情',
      component: NoticeDetailPage
    },
    {
      path: '/keepServices',
      name: '存取酒服务',
      component: KeepServicesPage
    },
    {
      path: '/keepDetail/:keepId',
      name: '存酒详情',
      component: KeepDetailPage
    },
    {
      path: '/chooseWithDraw/:tableId',
      name: '选择要取酒水',
      component: ChooseWithDrawPage
    },
    {
      path: '/callServices',
      name: '呼叫服务',
      component: CallServicesPage
    },
    {
      path: '/scanAction/:tableId',
      name: '扫码操作',
      component: ScanActionPage
    },
    {
      path: '/callKeepDetail/:tableId',
      name: '呼叫存酒详情',
      component: CallKeepDetailPage
    },
    {
      path: '/callServiceDetail/:tableId',
      name: '呼叫服务详情',
      component: CallServiceDetailPage
    },
    {
      path: '/complaintDetail/:tableId',
      name: '投诉建议详情',
      component: ComplaintDetailPage
    },
    {
      path: '/memberCard',
      name: '会员卡中心',
      component: MemberCardPage
    },
    {
      path: '/payCode',
      name: '支付二维码',
      component: PayCodePage
    },
    {
      path: '/cardList/:type',
      name: '会员卡列表',
      component: CardListPage
    },
    {
      path: '/cardDetail/:memberCardUserId/:type',
      name: '会员卡详情',
      component: CardDetailPage
    },
    {
      path: '/cardCharge/:memberCardUserId/:cardName/:cardNumber/:cardMinCharge',
      name: '会员卡充值',
      component: CardChargePage
    }
  ]
})

router.beforeEach((to, from, next) => {//验证
  //console.log(to, from)
  setTimeout(()=>{
    store.commit('updateLoadingStatus', {isLoading: true})
    if(sessionStorage.getItem("needBindPhone") && to.name != '绑定手机') next({path:'/bindPhone'})
    else next()
  },1)
});

router.afterEach((to, from) => {//验证
  if(from.path == '/'){
  }
});

export default router
